/*
** indirection_too_far.c for asm in /home/vanet_c//proj-kw/asm/folder_syntax
** 
** Made by charles-edouard vanet
** Login   <vanet_c@epitech.net>
** 
** Started on  Fri Dec 14 14:47:59 2012 charles-edouard vanet
** Last update Sat Dec 15 15:35:31 2012 charles-edouard vanet
*/

#include	"../../includes/asm.h"

void	indirection_too_far_error(t_list **file_list, t_my_file **file)
{
  my_fd_putchar('\t', 2);
  my_stderror((*file_list)->name);
  my_stderror(": Warning indirection too far line ");
  my_put_nbr_error((*file)->line_nb);
  my_fd_putchar('\n', 2);
}

int	my_str_is_num(char *str)
{
  int	i;

  i = 0;
  while (str[i] != '\0')
    {
      if (str[i] < '0' || str[i] > '9')
	return (1);
      i++;
    }
  return (0);
}

int	indirection_too_far(t_list **file_list, t_my_file **my_file)
{
  char	**tab;
  int	i;

  i = 0;
  tab = (*my_file)->tab_instruction;
  while (tab[i] != NULL)
    {
      if (my_str_is_num(tab[i]) == 0)
	if (atoi(tab[i]) > IDX_MOD) // ATTENTION ATOI A REMPLACER PAR MY_GETNBR APRES CORRECTION VALGRIND
	  indirection_too_far_error(file_list, my_file);
      i++;
    }
  return (0);
}
